package com.wdh.kjs.util;

/**
 * Created by lyh
 */
public class EditTextLengthUtil {
    public static int min_length = 6;
    public static int max_length = 16;
    public static String contain_num="需要包含数字";
    public static String contain_alphabet="需要包含字母";

    public static int check_length(String str) {
        int size = str.length();
        if (size > max_length) {
            return 1;
        } else if (size < min_length) {
            return -1;
        }
        return 0;
    }
    private static int check_length(String str, int minlen, int maxlen) {
        int size = str.length();
        if (size > maxlen) {
            return 1;
        } else if (size < minlen) {
            return -1;
        }
        return 0;
    }
    public static String check_numAndAlphabet(String str){
        String res="";
        if(check_alphabet(str).equals(contain_alphabet)){
            res="密码";
            res=res+contain_alphabet;
        }
        if(check_num(str).equals(contain_num)){
            if(res.equals("")||res.length()==0){
                res="密码";
                res=res+contain_num;
            }else{
                res=res+"和数字";
            }
        }
        return res;
    }

    public static String check_alphabet(String str){
        int i;
        for(i=0;i<str.length();i++){
            char ch=str.charAt(i);
            if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z'){
                return "";
            }
        }
        return contain_alphabet;
    }
    public static String check_num(String str){
        int i;
        for(i=0;i<str.length();i++){
            char ch=str.charAt(i);
            if(ch>='0'&&ch<='9'){
                return "";
            }
        }
        return contain_num;
    }
}
